using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.IO;
using System.Globalization;
using System.Threading;
using System.Data.SqlClient;
namespace Test {
	class Ferrum2 {
		static void MainX() {
			DAL dal=new DAL();
			dal.NonQry("truncate table usr");
			//dal.NonQry("drop table usr");
			//dal.NonQry("create table usr(id int identity,account varchar(8),firstname varchar(50),lastname varchar(50),email varchar(100),pwd varchar(50),birthdate date,postcode varchar(15))");
			using(StreamReader rdr=new StreamReader("data00.csv"))
			{
				int cnt=1;
				StringBuilder sb=new StringBuilder();
				while(!rdr.EndOfStream)
				{
					string[] line=rdr.ReadLine().Split('|');
					if(line.Length==7)
					{
						//dal.NonQry("insert into usr(account,email,pwd,firstname,lastname,birthdate,postcode)values('{0}','{1}','{2}','{3}','{4}','{5}','{6}')",line[0],line[1].Replace("'","''"),line[2].Replace("'","''"),line[3].Replace("'","''"),line[4].Replace("'","''"),line[5],line[6].Replace("'",""));
						sb.AppendFormat("insert into usr(account,email,pwd,firstname,lastname,birthdate,postcode)values('{0}','{1}','{2}','{3}','{4}','{5}','{6}')",line[0],line[1].Replace("'","''"),line[2].Replace("'","''"),line[3].Replace("'","''"),line[4].Replace("'","''"),line[5],line[6].Replace("'",""));
						sb.AppendLine();
						if(cnt++%1000==0)
						{
							dal.NonQry(sb.ToString());
							sb.Length=0;
						}
					}
					//else
					//Console.WriteLine(string.Join("|",line));
				}
			}
		}
	}
}
